<template>

  <!--开始必须新建一个div根目录-->
  <div>
      <h1>添加新闻</h1>
    <p>添加标题<input type="text" v-model="form.headline"></p>
    <p>添加内容<input type="text" v-model="form.content"></p>
    <p>
      <button @click="add">添加</button>
    </p>


    <h1>展示新闻</h1>
    <table border="1" cellpadding="0" cellspacing="0" align="center">
      <tr>
        <td>标题</td>
        <td>内容</td>
      </tr>
      <tr v-for="i in show_list">
        <td>{{i.headline}}</td>
        <td>{{i.content}}</td>
      </tr>
      <tr>
        <td colspan="2">
          <div v-for="i in tpage" style="float: left">
            <button @click="show_journalismM(i)">
              {{ i }}
            </button></div>
        </td>
      </tr>
    </table>

  </div>
</template>

<script>
export default {
  name: "add_journalismM",
  data() {
    return {
      form:{},
      show_list : [],
      tpage:0
    }
  },

  methods: {
    add(){
      this.$axios.post('users/journalisM/',this.form)
      .then(res=>{
        console.log(res.data)
        if (res.data.code == 200){
            alert("添加成功")
            this.form = {}
        }else{
            alert("添加失败")
        }
      })
    },


    show_journalismM(cpage){
      this.$axios.get('users/journalisM/?cpage='+cpage)
      .then(res=>{
        this.show_list = res.data.list
        this.tpage = res.data.tpage
      })
    }
  },

  computed: {},

  mounted() {
    this.show_journalismM(1)
  }
}
</script>

<style scoped>

</style>
